//
//  NSTextView.swift
//  JKTools
//
//  Created by 姜奎 on 2/20/25.
//

import AppKit

class JKTextView: NSTextView {
    private static var actionCloseAssociatedKey: Int = 0

    private var actionClose: ((NSTextView, NSEvent)-> Bool)?

    func addKeyDown(action:@escaping ((NSTextView, NSEvent)->Bool)) {
        self.actionClose = action
    }

    open override func keyDown(with event: NSEvent) {
        if let actionClose = actionClose, actionClose(self, event) {
            return
        }
        super.keyDown(with: event)
    }
}
